package vn.vnu.uet.university;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import vn.vnu.uet.university.bean.DatabaseHandler;
import vn.vnu.uet.university.bean.Tkb;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class Schedule extends DefaultActivity {
	ListView listContent;
	List<Tkb> tkbList = new ArrayList<Tkb>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState, R.layout.schedule);

		this.setTitle("Thời khoá biểu");
		DatabaseHandler db = new DatabaseHandler(Schedule.this);
		listContent = (ListView) findViewById(R.id.listContent);

		ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map = new HashMap<String, String>();

		tkbList = db.getAllTkb(Token.instance().user.id);

		for (int i = 0; i < tkbList.size(); i++) {
			map = new HashMap<String, String>();
			map.put("id", tkbList.get(i).getId());
			map.put("time", tkbList.get(i).getTime());
			map.put("name", tkbList.get(i).getName());
			map.put("place", tkbList.get(i).getPlace());
			listItem.add(map);
		}
		
		Toast.makeText(Schedule.this, tkbList.get(3).getPlace(), 10000).show();

		SimpleAdapter mSchedule = new SimpleAdapter(Schedule.this, listItem,
				R.layout.row4, new String[] { "id", "time", "name", "place" },
				new int[] { R.id.id, R.id.time, R.id.name, R.id.place });
		listContent.setAdapter(mSchedule);
	}
}
